<h1>Listing items</h1>

<table>
  <tr>
    <th>Category</th>
    <th>Brand</th>
    <th>Name</th>
    <th>Detail</th>
    <th>Price</th>
    <th>Quantity</th>
    <th>Bought date</th>
    <th>Expire date</th>
    <th>How many time left</th>
  </tr>

<% for item in @items %>
  <tr>
    <td><%=h item.category.catename %></td>
    <td><%=h item.brand.brandname %></td>
    <td><%=h item.name %></td>
    <td><%=h item.detail %></td>
    <td><%=h item.price %></td>
    <td><%=h item.quantity %></td>
    <td><%=h item.bought_date %></td>
    <td><%=h item.expire_date %></td>
    <td><%=h distance_of_time_in_words(Time.now, item.expire_date, true) %></td>
    <td><%= link_to 'Show', item %></td>
    <td><%= link_to 'Edit', edit_item_path(item) %></td>
    <td><%= link_to 'Destroy', item, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New item', new_item_path %><br />
<%= link_to 'Brands list', brands_path %><br />
<%= link_to 'Category management', categories_path %>
